package com.ad.nbi.FileTransferIRPSystem;

import org.omg.CORBA.ORB;

import com.ad.nbi.Constants;

import FileTransferIRPConstDefs.FileInfo;
import FileTransferIRPConstDefs.FileInfoListHolder;
import FileTransferIRPConstDefs.FileLocation;
import FileTransferIRPConstDefs.Result;
import FileTransferIRPSystem.FileDownloadIndication;
import FileTransferIRPSystem.GetFileTransferIRPNotificationsProfile;
import FileTransferIRPSystem.GetFileTransferIRPOperationsProfile;
import FileTransferIRPSystem.GetFileTransferIRPVersions;
import FileTransferIRPSystem.InvalidFileInfoList;
import FileTransferIRPSystem.InvalidTimes;
import FileTransferIRPSystem.ListAvailableFiles;
import ManagedGenericIRPConstDefs.Method;
import ManagedGenericIRPSystem.InvalidParameter;
import ManagedGenericIRPSystem.OperationNotSupported;
import TimeBase.UtcT;

/**
 * This class is the implemetation object for your IDL interface.
 * 
 * Let the Eclipse complete operations code by choosing 'Add unimplemented
 * methods'.
 */
public class FileTransferIRPServerImpl extends
		FileTransferIRPSystem.FileTransferIRPPOA {
	/**
	 * Constructor for FileTransferIRPServerImpl
	 */
	private ORB orb;

	public FileTransferIRPServerImpl() {
	}

	@Override
	public Result list_available_files(short management_data_type,
			UtcT begin_time, UtcT end_time, FileInfoListHolder file_info_list)
			throws InvalidParameter, ListAvailableFiles, InvalidTimes {

		FileLocation fl = new FileLocation();
		fl.file_location_directory("/home/MS/LOG/");
		fl.file_location_url("/home/MS/LOG/alarm_2013_04_02.log");
		TimeBase.UtcT beginTime = new UtcT();
		beginTime.time = System.currentTimeMillis() - 2 * 60 * 60 * 1000;

		TimeBase.UtcT expirationTime = new UtcT();
		expirationTime.time = System.currentTimeMillis() - 2 * 60 * 60 * 1000
				+ 30 * 24 * 60 * 60 * 1000;

		FileInfo f = new FileInfo(fl, 390506, beginTime, expirationTime,
				"gzip", "log");
		file_info_list.value = new FileInfo[] { f };
		// TODO Auto-generated method stub
		return Result.OK;
	}

	@Override
	public Result file_download_indication(FileInfo[] file_info_list)
			throws FileDownloadIndication, OperationNotSupported,
			InvalidFileInfoList {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String[] get_file_transfer_irp_versions()
			throws GetFileTransferIRPVersions {
		// TODO Auto-generated method stub
		return new String[] { Constants.VERSION.FileTransferIRP };
	}

	@Override
	public Method[] get_file_transfer_irp_operations_profile(String iRPVersion)
			throws GetFileTransferIRPOperationsProfile, InvalidParameter,
			OperationNotSupported {
		Method[] methods = new Method[] {
				new Method("list_available_files", new String[] {
						"management_data_type", "begin_time", "end_time",
						"file_info_list" }),
				new Method("file_download_indication",
						new String[] { "file_info_list" }),
				new Method("get_file_transfer_irp_versions",
						new String[] { "" }) };
		return methods;
	}

	@Override
	public Method[] get_file_transfer_irp_notifications_profile(
			String irp_version) throws GetFileTransferIRPNotificationsProfile,
			InvalidParameter, OperationNotSupported {
		Method[] methods = new Method[1];

		methods[0] = new Method("QualityOfServiceAlarm", new String[] { "" });

		return methods;
	}

	public void setOrb(ORB orb) {
		this.orb = orb;
	}
}
